import {Component} from "@angular/core";
import {ProductService} from "./service/product.service";
import {Product} from "./entity/product";
import {FaqService} from "./service/faq.service";
import {Faq} from "./entity/faq";

@Component({
    selector: "my-body",
    templateUrl: "./app/body.html",
    providers:[FaqService]
})
export class BodyComponent {
    private productService:ProductService;
    private faqList:Faq[];
    constructor(faqService:FaqService) {
        //接受到 service 组件返回的一个 可观察的 Response
        //subscribe 订阅它，
        //并将返回的 result 结果，调用json()方法
        //将其中 body 的 json 文本，转为json对象
        //最后赋值给 productList 成员变量
        faqService.getFaq()
            .subscribe(result=>this.faqList = result.json());
    }
}
